package cn.iot.sys.service.impl;

import cn.iot.common.dto.ResultMsg;
import cn.iot.sys.dao.SysPoliticalDao;
import cn.iot.sys.entity.SysPolitical;
import cn.iot.sys.service.SysPoliticalService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class SysPoliticalServiceImpl implements SysPoliticalService {
    @Resource
    private SysPoliticalDao sysPoliticalDao;
    private Logger logger = LoggerFactory.getLogger(getClass());

    @Override
    public ResultMsg getSysPoliticalList() {
        logger.info("SysPoliticalServiceImpl getSysPoliticalList start...");
        List<SysPolitical> sysPoliticalList = sysPoliticalDao.getSysPoliticalList();
        ResultMsg msg = new ResultMsg(200,"成功",sysPoliticalList);
        return msg;
    }

    @Override
    public ResultMsg getSysPoliticalByName(String politicalName) {
        logger.info("SysPoliticalServiceImpl getSysPoliticalByName politicalName{}",politicalName);
        SysPolitical sysPoliticalByName = sysPoliticalDao.getSysPoliticalByName(politicalName);
        ResultMsg msg;
        if (sysPoliticalByName == null){
            msg = new ResultMsg(500,"失败",null);
            return msg;
        }
        msg = new ResultMsg(200,"成功",sysPoliticalByName);
        return msg;
    }
}
